package com.hlhj.carview.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.hlhj.carview.Iview.AddEquipmentView
import com.hlhj.carview.bean.MyBaseBean
import com.hlhj.carview.http.Apis
import com.hlhj.carview.http.CustomAction
import com.hlhj.carview.http.LoadingAction
import com.lzy.okgo.model.Response

/**
 * Created by Never Fear   on 2018\12\24 0024.
Never More....
 */
class AddEquipmentModule :BaseModule {
    var l:AddEquipmentView?=null

    //申请设备
    fun addEquipment(name:String,phone:String,wechat:String,c: Context){
        Apis.addEquipment(name, phone, wechat)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MyBaseBean>>(c){
                                override fun httpSuccess(t: Response<MyBaseBean>) {
                                    l?.setAddResult(t.body())
                                }
                            })
                }
    }
    //设备保修
    fun repair(device_id:Int,proposer:String,proposer_phone:String,wechat:String,cause:String,img:String,c:Context){
        Apis?.repair(device_id, proposer, proposer_phone, wechat, cause, img)

                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MyBaseBean>>(c){
                                override fun httpSuccess(t: Response<MyBaseBean>) {
                                    l?.setRepair(t.body())
                                }
                            })
                }
    }
}